package com.project.class4_11;

public class Travel {
    public static void main(String[] args) {
        Man m=new Man();
        m.setTool(new car());
        m.travel();
        m.setTool(new plane());
        m.travel();
        m.setTool(new ship());
        m.travel();
    }
}
class Man{
    private Tool tool;
    public void setTool(Tool t){
        this.tool=t;
    }
    public void travel(){
        tool.run();
        System.out.println("-----玩耍");
        System.out.println();
    }
}
interface   Tool{
    public abstract void run();
}
class plane implements Tool{

    @Override
    public void run() {
        System.out.print("借助飞机飞到目的地");
    }
}
class ship implements Tool{

    @Override
    public void run() {
        System.out.print("通过轮船航行到目的地");
    }
}
class car implements Tool{

    @Override
    public void run() {
        System.out.print("借助汽车行驶到目的地");
    }
}